﻿
@page "/Wms/SaleOutWarehouseDetail/BatchEdit"
@using nERP.ViewModel.Wms.SaleOutWarehouseDetailVMs
@using System.ComponentModel.DataAnnotations
@inherits BasePage

<ValidateForm @ref="vform" Model="@Model" OnValidSubmit="@Submit">
  <div style="margin-bottom:10px;"> @WtmBlazor.Localizer["Sys.BatchEditConfirm"]</div>
  <Row ItemsPerRow="ItemsPerRow.Two" RowType="RowType.Normal">
    <BootstrapInput @bind-Value="@Model.LinkedVM.Seq"/>
    <Select @bind-Value="@Model.LinkedVM.SaleOutWarehouseId" Items="AllSaleOutWarehouses" Id="gbc8993c484f2431fafa891537b97340a"/>
    <Select @bind-Value="@Model.LinkedVM.SaleId" Items="AllSales" Id="g48290d83a4ce495cbd4ca76a8db6ee37"/>
    <Select @bind-Value="@Model.LinkedVM.SaleDetailId" Items="AllSaleDetails" Id="g7f071c8455e4468fa79a73c952f31dc7"/>
    <Select @bind-Value="@Model.LinkedVM.GoodsId" Items="AllGoodss" Id="gca8cc1576ac14f568df4a8ac9d4fbb3f"/>
    <BootstrapInput @bind-Value="@Model.LinkedVM.GoodsName"/>
    <BootstrapInput @bind-Value="@Model.LinkedVM.GoodsSpec"/>
    <BootstrapInput @bind-Value="@Model.LinkedVM.GoodsUnit"/>
    <Select @bind-Value="@Model.LinkedVM.WarehouseId" Items="AllWarehouses" Id="g18e6f0dccbc044d59cb253a62a176675"/>
    <BootstrapInput @bind-Value="@Model.LinkedVM.SaleOutNumber"/>
    <BootstrapInput @bind-Value="@Model.LinkedVM.Remark"/>
  </Row>

  <div class="modal-footer table-modal-footer">
    <Button ButtonType="ButtonType.Submit" IsAsync="true" Text="@WtmBlazor.Localizer["Sys.Submit"]"/>
    <Button OnClick="OnClose" Text="@WtmBlazor.Localizer["Sys.Close"]"/>
  </div>

</ValidateForm>



@code {
    [Parameter]
    public string id { get; set; }
    [Parameter]
    public string[] ids { get; set; }
    private SaleOutWarehouseDetailBatchVM Model = new SaleOutWarehouseDetailBatchVM();
    private ValidateForm vform { get; set; }
    
    private async Task Submit(EditContext context)
    {
        Model.Ids = ids;
        await PostsForm(vform, "/api/Wms/SaleOutWarehouseDetail/BatchEdit", (s) => WtmBlazor.Localizer["Sys.BatchEditSuccess", s], method: HttpMethodEnum.POST);
    }
            

    public void OnClose()
    {
        CloseDialog();
    }
    
    private List<SelectedItem> AllSaleOutWarehouses = new List<SelectedItem>();
    private List<SelectedItem> AllSales = new List<SelectedItem>();
    private List<SelectedItem> AllSaleDetails = new List<SelectedItem>();
    private List<SelectedItem> AllGoodss = new List<SelectedItem>();
    private List<SelectedItem> AllWarehouses = new List<SelectedItem>();
    protected override async Task OnInitializedAsync()
    {
        
        
        AllSaleOutWarehouses = await WtmBlazor.Api.CallItemsApi("/api/Wms/SaleOutWarehouseDetail/GetSaleOutWarehouses");
        AllSaleOutWarehouses.Insert(0, new SelectedItem { Text = WtmBlazor.Localizer["Sys.PleaseSelect"],Value = "" });
        AllSales = await WtmBlazor.Api.CallItemsApi("/api/Wms/SaleOutWarehouseDetail/GetSales");
        AllSales.Insert(0, new SelectedItem { Text = WtmBlazor.Localizer["Sys.PleaseSelect"],Value = "" });
        AllSaleDetails = await WtmBlazor.Api.CallItemsApi("/api/Wms/SaleOutWarehouseDetail/GetSaleDetails");
        AllSaleDetails.Insert(0, new SelectedItem { Text = WtmBlazor.Localizer["Sys.PleaseSelect"],Value = "" });
        AllGoodss = await WtmBlazor.Api.CallItemsApi("/api/Wms/SaleOutWarehouseDetail/GetGoodss");
        AllGoodss.Insert(0, new SelectedItem { Text = WtmBlazor.Localizer["Sys.PleaseSelect"],Value = "" });
        AllWarehouses = await WtmBlazor.Api.CallItemsApi("/api/Wms/SaleOutWarehouseDetail/GetWarehouses");
        AllWarehouses.Insert(0, new SelectedItem { Text = WtmBlazor.Localizer["Sys.PleaseSelect"],Value = "" });

        await base.OnInitializedAsync();
    }
}
